import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css
import App from './App'

import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
import i18n from '@/Lang'

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

Vue.config.productionTip = false

import { imgerr } from '@/directive'
Vue.directive('imgerr', imgerr)

// 全局注册组件方便四处使用
import myComponents from '@/components'
Vue.use(myComponents)

// 过滤器的注册
import * as filters from '@/filters'
// Vue.filter(函数名, 函数体) 就可以注册过滤器
for (const key in filters) {
  const name = key
  const fn = filters[key]
  Vue.filter(name, fn)
}

// 混入  mixin
import mixin from '@/mixin'
Vue.mixin(mixin)

new Vue({
  el: '#app',
  i18n,
  router,
  store,
  render: h => h(App)
})
